<template>
  <div class="app-container">
      通知标题：
       <el-input v-model="params.noticeTitle" placeholder="请输入通知标题"></el-input>
       通知发布范围：
       <el-select v-model="params.targetType" placeholder="请选择">
          <el-option
            v-for="item in options"
            :key="item.value"
            :label="item.label"
            :value="item.value">
          </el-option>
        </el-select>
        <br>
        通知类型：
       <el-input v-model="params.noticeType" placeholder="请输入通知类型"></el-input><br>
       通知内容：
      <tinymce :height="300" v-model="params.content"></tinymce>
      <el-button type="primary" @click="addNotice">提交</el-button>
  </div>
</template>
<script>
import tinymce  from '@/components/Tinymce'
import { addNotice } from '@/api/notice'
export default {
    components: {
        tinymce 
    },
  data() {
    return {
      params:{
        content:'',
        noticeTitle:'',
        noticeType:'',
        targetType:'',
      },
      options: [{
          value: '0',
          label: '公开'
        }, {
          value: '1',
          label: '用户'
        }, {
          value: '2',
          label: '学生'
        }, {
          value: '3',
          label: '教师'
        }],
        
    }
  },
   methods: {
      addNotice() {
        addNotice(this.params).then(()=>{
            this.$message({
              type: 'success',
              message: '新建通知成功!'
            })
            this.$router.go(-1)
            }
          ).catch(err=>{
            this.$message({
              type: 'success',
              message: '新建通知失败!'
            })
            })

      }
   }
}
</script>
